<!--
 * @Descripttion: 
 * @version: 
 * @Author: cyj
 * @Date: 2022-12-23 17:13:42
-->
<template>
    <div class="newalbum">
        <div class="week">
            <div class="title">
                <span>本周新碟</span>
            </div>
            <div class="content">
                <AlbumList :weekAlbumList="discover.weekNewSongsList"></AlbumList>
            </div>    
        </div>
    </div>
</template>

<script setup>
import {useDiscover} from '@/store/discovermusic'
import AlbumList from '@/components/content/albumlist/AlbumList.vue'
import { getNewAlbum } from '@/api/findmusic/newsongs/newsongs'
import { ref, onMounted } from 'vue'
let weekAlbumList = ref([])
let monthAlbumList = ref([])

//创建仓库实例
const discover = useDiscover()


//获取新碟上映数据
async function getAlbumList() {
    let res = await getNewAlbum()
    if (res.status === 200) {
        weekAlbumList.value = res.data.weekData
        monthAlbumList.value = res.data.monthData
        //存到仓库中
        discover.weekNewSongsList = weekAlbumList.value
    }
}

onMounted(() => {
    if(discover.weekNewSongsList.length === 0){
        getAlbumList()
    }
})

</script>

<style lang="scss" scoped>
.newalbum {
    .week {
        .title {
            span {
                font-size: 18px;
            }
        }
        .content {

        }

    }
}
</style>